<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body style="font-family:Arial, Helvetica, sans-serif">
<h1>Trainees Need To Approval</h1>

<form id="form1" name="form1" method="post" action="">
  <label for="password">1) Input Your Attendance Password Here </label>
  <input type="password" name="password" id="password" />

<br />
<br />
2) 
Click The Button To Take Action<br />
<table width="1100" border="1" cellspacing="0" cellpadding="10">
  <tr>
    <th width="41" scope="col">No</th>
    <th width="59" scope="col">Staff</th>
    <th width="114" scope="col">Full Name</th>
    <th width="158" scope="col">Registered On</th>
    <th width="87" scope="col">Belongs To Shop</th>
    <th width="52" scope="col">Manager</th>
    <th width="30" scope="col">Train Time</th>
    <th width="52" scope="col">Password <br />
      Status<br /></th>
    <th colspan="3" scope="col">Action</th>
  </tr>
 <?php 
 $stDetail = new Model_DbTable_Roster_Stafflogindetail();
 $attRecord = new Model_DbTable_Roster_Attnrecord();
 $roster = new Model_DbTable_Roster_Timesheet();
 $dateYesterday = Model_DatetimeHelper::adjustDays('sub', Model_DatetimeHelper::dateToday(), 1);
 foreach($this->stList as $k => $v){
 	$stLine = $stDetail->getDetail($v['id_staff']);
 	$mgLine = $stDetail->getDetail($v['id_manager_introduce']);
 	
 	$stfRoster = $roster->listShiftByStaffIdByDate($v['id_staff'], $v['register_date'], $dateYesterday);
 	$totalH = 0;
 	foreach ($stfRoster as $value){
 		$hour = 0;
 		$tmphour = round(($value['shift_end'] - $value['shift_begin'])/3600,1);
 		if($tmphour >= 9){
 			$hour = $tmphour - 1;
 		}elseif($tmphour > 5){
 			$hour = $tmphour - 0.5;
 		}else{
 			$hour = $tmphour;
 		}
 		$totalH += $hour;
 	}
 	?> 
  <tr>
    <td><?php echo $k + 1;?></td>
    <td><?php echo ucfirst($stLine['ni']); ?></td>
    <td><?php echo $v['first_name']." ".$v['last_name']?> </td>
    <td><?php echo $v['register_date']?></td>
    <td style="width:120px; font-size:12px;">
    <?php 
    $shList = $attRecord->getShopHeadByStaffId($v['id_staff']);
    if(!empty($shList)){
    	foreach($shList as $sh){
    		echo Model_EncryptHelper::getSslPassword($sh["sh"]);
    		echo ", ";
    	}
    }
    
    ?>
    </td>
    <td><?php echo $mgLine['ni']?></td>
    <td><?php echo "Hour:".$totalH?></td>
    <td align="center"><?php
    date_default_timezone_set("Australia/Melbourne");
	$dateExp = $stLine['expire_date'];
	$strImg = '';
	if($dateExp == '2037-12-31'){
		$strImg = '<img src="/im/yes20.jpg" alt="Already Got All Document Paper,Password Never Expire" title="Already Got All Document Paper,Password Never Expire" />';
		}
	else{
		$strImg = '<img src="/im/btn_edit_error.png" title="Still did not have paper document back to office yet, password will expire,if you pass trainee for this staff, the password expire date will be extended." alt="Still did not have paper document back to office yet, password will expire,if you pass trainee for this staff, the password expire date will be extended." />';
		}	
	$intToday = Model_DatetimeHelper::tranferToInt(Model_DatetimeHelper::dateToday());
	$intExp =   Model_DatetimeHelper::tranferToInt($dateExp);
	if($intExp < $intToday){	
		$strImg= '<img src="/im/no20.jpg" title="Password Expired, if you pass trainee for this staff, the password expire date will be extended." alt="Password Expired, if you pass trainee for this staff, the password expire date will be extended." />';
	}
	
	echo $strImg;
	?></td>
    <td width="75" align="center"><input type="submit" name="btn_pass[<?php echo $v['id_staff']?>]" id="btn_pass_<?php echo $v['id_staff']?>" value="Pass Training" onclick="javascript: return confirm('Are you sure you want to pass the trainning ?')" /></td>
    <td align="center"><input type="submit" name="btn_not_pass[<?php echo $v['id_staff']?>]" id="btn_not_pass_<?php echo $v['id_staff']?>" value="Fail Training" onclick="javascript: return confirm('Warning :Please Confirm You want to Fail the Trainee')" /></td>
    <td align="center"><a href = "http://<?php echo WEB_IP?>/rosteraudit/change-rate-apply/id/<?php echo $v['id_staff'];?>" style="font-size:13px;">Update Rate</a></td>
  </tr>
 <?php }?> 
</table>
</form>

<h1>History </h1>

<table width="900" border="1" cellspacing="0" cellpadding="10" style="font-size:12px;">
  <tr>
    <th scope="col">Order</th>
    <th scope="col">Date</th>
    <th scope="col">Staff</th>
    <th scope="col">Manager</th>
    <th scope="col">Pass/ Fail</th>
    <th scope="col">Change Rate</th>
  </tr>
 <?php 
 if(!empty($this->history)){
 foreach($this->history as $k => $v){
	 
	 $stLine2 = $stDetail->getDetail($v['id_staff']);
 ?> 
  <tr>
    <td><?php echo $k + 1;?></td>
    <td><?php echo $v['action_time']?></td>
    <td><?php echo $stLine2['ni']?></td>
    <td><?php echo ($v['id_manager'] == 4)?"Simon":"Admin";?></td>
    <td><?php echo ($v['action']== 2)?'Pass':'Failed';?></td>
    <td><?php if($v['action'] == 2){?><a href = "http://<?php echo WEB_IP?>/rosteraudit/change-rate-apply/id/<?php echo $v['id_staff'];?>">Update Rate</a><?php }?></td>
  </tr>
<?php 
 }
 }
?>  
</table>

</body>
</html>
